package com.logic.modular.game.player.bag.service.handler;

import com.comment.pojo.domain.logic.core.CoreProp;
import com.logic.modular.game.player.bag.dto.UsePropDto;
import com.logic.modular.game.player.info.service.PlayerStatusServiceImpl;
import com.logic.modular.game.PvpCity;
import com.logic.modular.game.player.match.service.PvpCityServiceImpl;
import com.logic.modular.gameCore.cultivate.prop.CorePropServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

@Service
public  class prop2004 implements PropType2Handler { // 2004	招兵买马	2	使用可获得10000的预备兵
    @Resource
    private PvpCityServiceImpl pvpCityService;
    @Resource
    private PlayerStatusServiceImpl playerStatusService;

    @Override
    public void handler(UsePropDto dto) {
        Long uid = dto.getUid();
        Long corePropId = dto.getCorePropId();
        BigDecimal num = dto.getNum();

        Long cityId = dto.getCityId();
        Long matchId = playerStatusService.get(uid).getCurrentMatchId();

        PvpCity playerCity = pvpCityService.getPlayerCity(uid, cityId, matchId);
        CoreProp cache = CorePropServiceImpl.getCache(corePropId);
        long l = -corePropId;
        Integer i = cache.getUseValue().get(l);
        playerCity.setReadyArmy(
                playerCity.getReadyArmy() + (long) 10000 * num.intValue()
        );
        pvpCityService.update(playerCity);
    }
}
